﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#include "ComboBoxDefinitionReference.h"
#include "IComboBoxHandler.h"
#include "EnableCompileWarning_The_LAST_IncludeInCpp.h"

using namespace gcmp;

gcmp::ComboBoxDefinitionReference::ComboBoxDefinitionReference(ComboBoxDefinition* pComboBoxDefinition)
    :m_pComboBoxDefinition(pComboBoxDefinition)
{

}

gcmp::ComboBoxDefinitionReference::~ComboBoxDefinitionReference()
{

}

bool gcmp::ComboBoxDefinitionReference::AddItem(const std::wstring& item, Any useData)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pComboBoxDefinition, L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->AddItem(item, useData);
}

std::vector<std::wstring> gcmp::ComboBoxDefinitionReference::GetAllItems() const
{
    std::vector<std::wstring> res;
    DBG_WARN_AND_RETURN_UNLESS(m_pComboBoxDefinition, res, L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->GetAllItems();
}

bool gcmp::ComboBoxDefinitionReference::DeleteItem(int index)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pComboBoxDefinition, L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->DeleteItem(index);
}

bool gcmp::ComboBoxDefinitionReference::DeleteAllItems()
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pComboBoxDefinition, L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->DeleteAllItems();
}

bool gcmp::ComboBoxDefinitionReference::InsertItem(int index, const std::wstring &text, Any useData /*= Any()*/)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pComboBoxDefinition, L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->InsertItem(index, text, useData);
}

bool gcmp::ComboBoxDefinitionReference::SetCurrentIndex(int currentIndex)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pComboBoxDefinition, L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->SetCurrentIndex(currentIndex);
}

int gcmp::ComboBoxDefinitionReference::GetCurrentIndex() const
{
    DBG_WARN_AND_RETURN_UNLESS(m_pComboBoxDefinition, -1,  L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->GetCurrentIndex();
}

std::wstring gcmp::ComboBoxDefinitionReference::GetCurrentText() const
{
    DBG_WARN_AND_RETURN_UNLESS(m_pComboBoxDefinition, L"", L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->GetCurrentText();
}

gcmp::Any gcmp::ComboBoxDefinitionReference::GetCurrentData() const
{
    DBG_WARN_AND_RETURN_UNLESS(m_pComboBoxDefinition, Any(), L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->GetCurrentData();
}

gcmp::IComboBoxEvent* gcmp::ComboBoxDefinitionReference::GetEvent() const
{
    DBG_WARN_AND_RETURN_NULLPTR_UNLESS(m_pComboBoxDefinition, L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->GetEvent();
}

gcmp::IControlDefinitionChangeEvent* gcmp::ComboBoxDefinitionReference::GetControlDefinitionChangeEvent() const
{
    if (m_pComboBoxDefinition)
    {
        return m_pComboBoxDefinition->GetControlDefinitionChangeEvent();
    }
    return nullptr;
}

std::wstring gcmp::ComboBoxDefinitionReference::GetId() const
{
    DBG_WARN_AND_RETURN_UNLESS(m_pComboBoxDefinition, L"", L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->GetId();
}

std::wstring gcmp::ComboBoxDefinitionReference::GetCaption() const
{
    DBG_WARN_AND_RETURN_UNLESS(m_pComboBoxDefinition, L"", L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->GetCaption();
}

std::wstring gcmp::ComboBoxDefinitionReference::GetTooltip() const
{
    DBG_WARN_AND_RETURN_UNLESS(m_pComboBoxDefinition, L"", L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->GetTooltip();
}

bool gcmp::ComboBoxDefinitionReference::IsVisible() const
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pComboBoxDefinition, L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->IsVisible();
}

bool gcmp::ComboBoxDefinitionReference::IsEnabled() const
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pComboBoxDefinition, L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->IsEnabled();
}

bool gcmp::ComboBoxDefinitionReference::SetEnabled(bool enabled)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pComboBoxDefinition, L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->SetEnabled(enabled);
}

bool gcmp::ComboBoxDefinitionReference::SetVisible(bool visible)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pComboBoxDefinition, L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->SetVisible(visible);
}

bool gcmp::ComboBoxDefinitionReference::SetControlHandler(OwnerPtr<IComboBoxHandler> pControlHandler)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pComboBoxDefinition, L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->SetControlHandler(TransferOwnership(pControlHandler));
}

bool gcmp::ComboBoxDefinitionReference::BlockControlHandler(bool needBlock)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pComboBoxDefinition, L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->BlockControlHandler(needBlock);
}

bool gcmp::ComboBoxDefinitionReference::InsertItem(int index, const std::wstring &text)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pComboBoxDefinition, L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->InsertItem(index, text);
}

bool gcmp::ComboBoxDefinitionReference::AddItem(const std::wstring& item)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pComboBoxDefinition, L"m_pComboBoxDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pComboBoxDefinition->AddItem(item);
}
